const input = document.getElementById("text-input");
const btn = document.getElementById("check-btn");
const result = document.getElementById("result");

const wRegex = /\W/ig;
const nonAlphaReg = /_/ig;


btn.addEventListener("click", () => {
  const val = input.value;
  if (!val) alert("Please input a value");
  const newVal = val
      .toLowerCase()
      .replace(wRegex, "")
      .replace(nonAlphaReg, "");
  if (newVal === newVal
      .split("")
      .reverse()
      .join("")
  ) result.innerText = `${val} is a palindrome`;
  else result.innerText = `${val} is not a palindrome`;
})